﻿<div ms-controller="KDDYLIST">
    <!-- 添加按钮 -->
    <!--<div class="btn-add">
        <button type="button" class="btn btn-info btn-lg" ms-click="AddView('CCXJ')"><i class="iconfont icon-jiahao ft12 mr5"></i>添加出差休假</button>
    </div>-->
    <!-- 按条件选择 -->
    <div class="tab-filter-type">
        <div class="oh">
            <h5 class="pull-left tr">快递：</h5>
            <ul class="tab-type ft14">
                <li ms-click="SelectXJType('')"><span class="active">全部</span></li>
                <li ms-repeat-el="TypeData" ms-click="SelectXJType(el.ID)"><span>{{el.KDName}}</span></li>
            </ul>
        </div>

        <!-- 搜索 -->
        <div class="oh">
            <div class="input-group ml15" style="width:295px;">
                <input type="search" class="form-control" ms-duplex="search.searchcontent" placeholder="搜素快递信息">
                <span class="input-group-addon" ms-click="GetLIST()">搜索</span>
            </div>
        </div>
    </div>
    <!-- 展开更多选项 -->
    <div class="add-tab ft14 tc mt20" style="display:none;">
        <span>更多筛选<i class="caret"></i></span>
    </div>
    <!-- 表格 -->
    <div class="default-tab ft14 pt20">
        <table class="table table-striped table-responsive table-hover">
            <thead>
                <tr>
                    <th class="tc">
                        <div class="icheckbox_square-blue">
                            <input type="checkbox">
                            <span class="iconfont icon-check ft12"></span>
                        </div>
                    </th>
                    <!--<th ms-repeat-im="ShowColumns" ms-css-width="im.width" ms-visible="im.IsSel">{{im.ColText}}</th>-->
                    <th style="width:10%;">快递公司</th>
                    <th style="width:10%;">打印人</th>
                    <th style="width:17%;">时间</th>
                    <th>快递信息</th>
                    <th style="width:80px;">
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr ms-repeat-el="ListData" ms-on-mouseover="mouseover" ms-on-mouseout="mouseout">
                    <td class="tc">
                        <div class="icheckbox_square-blue">
                            <input type="checkbox">
                            <span class="iconfont icon-check ft12"></span>
                        </div>
                    </td>
                    <!--<td ms-repeat-im="ShowColumns" ms-visible="im.IsSel">{{FnFormat(el[im.ColName],im)|html}}</td>-->
                    <td style="width:10%;">{{el.KDName}}</td>
                    <td style="width:10%;">{{FnFormat(el.CRUser,{"format": "username"})|html}}</td>
                    <td style="width:17%;">{{el.CRDate|date("yyyy-MM-dd HH:mm")}}</td>
                    <td>{{FnFormat(el.Info,{"format": "dyxx"})|html}}</td>
                    <td>
                        <span class="tool" style="display:none;">
                            <a class="cz-btn ft18 bj-color tip" data-toggle="tooltip" title="打印" ms-if="el.CRUser==userName" ms-click="DYKDD(el.ID,$event)">
                                <i class="iconfont icon-dayin"></i>
                            </a>
                            <a class="cz-btn ft18 sc-color tip" data-toggle="tooltip" title="删除" ms-if="el.CRUser==userName" ms-click="DELDYJL(el,$event)">
                                <i class="iconfont icon-shanchu"></i>
                            </a>
                        </span>
                    </td>
                </tr>

            </tbody>
            <tfoot>
                <tr ms-if="isnull"><td class="tc"></td><td>暂无数据</td></tr>
            </tfoot>
        </table>
        <div class="ui-datatable-page ft14 pl20">

            <div id="pageDiv" ms-visible="model.page.total>model.pageNum[0].num" class="pull-right"></div>
            <div class="pull-right" ms-visible="ListData.size()!=0">
                <span>共{{model.page.total}}条记录</span>
                <span ms-visible="model.page.total>model.pageNum[0].num">
                    选择每页条数
                    <select style="height: 25px; width: 50px;" ms-change="selNum(this.value)" ms-duplex="model.page.pagecount">
                        <option ms-repeat-pg="pageNum" ms-attr-value="pg.num" ms-attr-selected="pg.num==model.page.pagecount?'selected':''">{{pg.num}}</option>
                    </select>
                </span>
            </div>

        </div>
    </div>
</div>

<script>

    var tempindex = avalon.define({
        $id: "KDDYLIST",
        curXJType: "",
        SelectXJType: function (type) {
            tempindex.curXJType = type;
            tempindex.GetLIST();
        },
        selNum: function (item) {    //选择显示的条数
            model.page.pagecount = item;
            tempindex.GetLIST();
        },
        InitWigetData: function () {

            //显示的列名
            model.ShowColumns.clear();
            //model.ShowColumns.pushArray([
            //    { "ColName": "KDName", "ColText": "快递公司", "width": "10%", "IsSel": true },
            //    { "ColName": "CRUser", "ColText": "打印人", "width": "10%", "IsSel": true, "format": "username" },
            //    { "ColName": "CRDate", "ColText": "时间", "width": "17%", "IsSel": true },
            //    { "ColName": "Info", "ColText": "快递信息", "width": "", "IsSel": true, "format": "dyxx" }
            //]);
            //类型数据

            $.getJSON('/API/VIEWAPI.ashx?Action=KDDY_GETPZLIST', function (resultData) {
                if (resultData.ErrorMsg == "") {
                    model.TypeData = resultData.Result;
                }
            })

            tempindex.GetLIST();
        },

        GetLIST: function () {
            model.page.pageindex = 1;
            model.ListData.clear();
            $.getJSON('/API/VIEWAPI.ashx?Action=KDDY_GETDYLIST', { p: 1, Content: model.search.searchcontent, pagecount: model.page.pagecount, lb: tempindex.curXJType }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    model.ListData = resultData.Result;
                    if (model.ListData.size() == 0) { model.isnull = true; } else { model.isnull = false; }
                    model.page.total = resultData.Result1;
                    laypage({
                        cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                        pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / model.page.pagecount), //通过后台拿到的总页数
                        curr: 1, //初始化当前页
                        skin: 'molv',
                        jump: function (e) { //触发分页后的回调
                            if (e.curr != model.page.pageindex) {
                                $.getJSON('/API/VIEWAPI.ashx?Action=KDDY_GETDYLIST', { p: e.curr, Content: model.search.searchcontent, pagecount: model.page.pagecount, lb: tempindex.curXJType }, function (resultData) {
                                    if (resultData.ErrorMsg == "") {
                                        model.ListData = resultData.Result;
                                    }
                                })
                                model.page.pageindex = e.curr;
                            }
                        }
                    });
                }
            })
        },
        DYKDD: function (ID, event) {
            if (event.stopPropagation) {
                event.stopPropagation();
            }
            //top.ComFunJS.winviewform("/ViewV4/AppPage/APPCOMMON.html?FormCode=" + model.PathCode + "_" + model.FormCode + "&ID=" + ID, "打印快递单", "1200", "");
            top.ComFunJS.winviewform("/ViewV5/AppPage/KDDY/KDDYYL.html?ID=" + ID, "打印快递单", "1200", "");
        },
        DELDYJL: function (item, event) {
            if (event.stopPropagation) {
                event.stopPropagation();
            }
            top.ComFunJS.winconfirm("确认要删除记录吗？", function () {
                $.post("/API/VIEWAPI.ashx?ACTION=KDDY_DELDYJL", { P1: item.ID }, function (result) {
                    var jsonresult = $.parseJSON(result)
                    if ($.trim(jsonresult.ErrorMsg) == "") {
                        model.ListData.remove(item);
                        top.ComFunJS.winsuccess("删除成功");
                    }
                });
            })
        }
    })
    //@ sourceURL=KDDYLIST.js;
</script>
